<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>${o.title }</title>
		<jsp:include page="../../../inc/css.jsp"></jsp:include>
		<jsp:include page="../../../inc/js.jsp"></jsp:include>
		<jsp:include page="../../../inc/xheditor.jsp"></jsp:include>
		<script type="text/javascript">
	$(function() {
		$("#back").button().click(function() {
			window.history.back();
		});
		$("#close").button().click(function() {
			window.close();
		});
		$('#content').xheditor({upLinkUrl:"upload.do",upLinkExt:"zip,rar,txt,doc,docx,xls,ppt",upImgUrl:"upload.do",upImgExt:"jpg,jpeg,gif,png",upFlashUrl:"upload.do",upFlashExt:"swf",upMediaUrl:"upload.do",upMediaExt:"avi",onUpload:insertUpload});
		$('#content').xheditor({tools:'full'});
		$("#add").button().click(function() {
			$.ajax( {
				type : "POST",
				url : "saveNews.do",
				data : {
					id : $("#id").val(),
					classid : $("#classid").val(),
					title : $("#title").val(),
					content : $("#content").val(),
					attach:$("#attach").val()
				},
				error : function() {
					alert("加载错误")
				},
				success : function(data) {
					alert(data);
				}
			});
		});
	});
	function insertUpload(data){
		$("#files").append(data+' <a href="'+data+'" target="_blank">下载</a><br/>');
		$("#attach").val($("#attach").val()+','+data);
	}
</script>
	</head>
	<body>
	<jsp:include page="../../../head.jsp"></jsp:include>
		<div class="container">
			<div class="header"></div>
			<div class="mainContent">
				<div class="content">
					<div id="editor">
					<form action="saveNews.do" method="post">
						<label>
							标题：
						</label>
						<input type="text" id="title" name="title" style="width: 600px;"
							value="${o.title}">
						<input type="hidden" name="id" id="id" value="${o.id }">
						<input type="hidden" name="classid" id="classid"
							value="${o.classid }">
						<textarea id="content" name="content" style="width: 700px; height: 500px;">${o.content }</textarea>
						<span style="color:#555555">附件：</span><br/><div id="files"><c:forEach var="e" items="${attach}">${e.url} <a href="${e.url}" target="_blank">下载</a><br/></c:forEach></div>
						<input type="hidden" id="attach" value="<c:forEach var="e" items="${attach}">${e.url},</c:forEach>">
					</form>
					<center>
						<button id="add">
							发布
						</button>
						<button id="back">
							返回
						</button>
						<button id="close">
							关闭
						</button>
					</center>
				</div>
				</div>
			</div>
			<div class="footer"><jsp:include page="../../../foot.jsp"></jsp:include></div>
		</div>
	</body>
</html>